package net.esj.basic.plugins.view.easyui.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class EasyUITreeEntity implements Cloneable{

	private String id;
	private String pId;
	private String text;
	private String iconCls;
	private Boolean checked = false;
	private String state;
	private Collection<EasyUITreeEntity> children;
	private Map<String,Object> attributes = new HashMap<String, Object>(0);
	
	public static final String STATE_CLOSE="closed";
	public static final String STATE_OPEN="open";
	
	public EasyUITreeEntity() {
		super();
		this.children = new ArrayList<EasyUITreeEntity>();
	}
	
	public EasyUITreeEntity(String id, String text) {
		this.id = id;
		this.text = text;
		this.children = new ArrayList<EasyUITreeEntity>();
	}
	
	public EasyUITreeEntity(String id, String text,String state) {
		this.id = id;
		this.text = text;
		this.state = state;
		this.children = new ArrayList<EasyUITreeEntity>();
	}
	
	public EasyUITreeEntity(String id, String text,String state,String pId) {
		this.id = id;
		this.text = text;
		this.state = state;
		this.pId = pId;
		this.children = new ArrayList<EasyUITreeEntity>();
	}
	
	public EasyUITreeEntity(String id, String text, String iconCls,
			boolean checked, String state) {
		super();
		this.id = id;
		this.text = text;
		this.iconCls = iconCls;
		this.checked = checked;
		this.state = state;
		this.children = new ArrayList<EasyUITreeEntity>();
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getIconCls() {
		return iconCls;
	}
	public void setIconCls(String iconCls) {
		this.iconCls = iconCls;
	}
	
	public Boolean getChecked() {
		return checked;
	}
	public void setChecked(Boolean checked) {
		this.checked = checked;
	}

	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public Collection<EasyUITreeEntity> getChildren() {
		return children;
	}
	public void  setChildren(Collection children) {
		this.children = children;
	}
	
	public String getPId() {
		return pId;
	}

	public void setPId(String pId) {
		this.pId = pId;
	}
	
	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public EasyUITreeEntity clone(){
		EasyUITreeEntity c = new EasyUITreeEntity();
		c.setChecked(getChecked());
		c.setChildren(new ArrayList<EasyUITreeEntity>(getChildren()));
		c.setIconCls(getIconCls());
		c.setId(getId());
		c.setState(getState());
		c.setText(getText());
		
		return c;
	}
	
}
